<link rel="stylesheet" href="<?php echo ThemePath(); ?>/css/jquery-ui.css">
<script src="<?php echo ThemePath(); ?>/js/jquery-ui.js"></script>
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'profiles-form',
    'htmlOptions' => array(
        'onsubmit' => "return false;", /* Disable normal form submit */
        'onkeypress' => " if(event.keyCode == 13){ send(); } " /* Do ajax call when user presses enter key */
    ),
    'action' => $this->createUrl('Users/updateprofile'),
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>

<div class="tab-pane container active mopo" id="profile-edit">
    <div class="edit-wrap">       
        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 column6 padding-zero-left">
            <figure>
                <?php $trainerProfileImage = ($profiles->photo != '') ? getRequestbaseUrl() . getuploadFolderDir() . $profiles->user_id . '/profile/432X324/' . $profiles->photo : getWorkNoshopimage(SkillConfig::skill_trainer_profile); ?>
                <div id="userPhoto"><img src="<?php echo $trainerProfileImage; ?>" alt="edit profile" class="img-responsive"></div>
                <div id="userPhotomessage" class="errorMessage"></div>
            </figure>
            <div class="clearfix"></div>
            <div class="gap"></div>
            <div class="select-pic">
                <small><?php echo SkillConfig::MAX_IMAGE_SIZE; ?></small>
                <?php
                $this->widget('common.extensions.EAjaxUpload.EAjaxUpload', array(
                    'id' => 'uploadFile',
                    'config' => array(
                        'action' => Yii::app()->createUrl('users/uploadphoto/id/' . $profiles->profile_id),
                        'allowedExtensions' => array("jpg", "jpeg", "gif", "png", "JPG", "JPEG", "GIF", "PNG"), //array("jpg","jpeg","gif","exe","mov" and etc...
                        'sizeLimit' => 2 * 1024 * 1024, // maximum file size in bytes
                        'minSizeLimit' => 1 * 1024, // minimum file size in bytes
                        'onComplete' => "js:function(id, fileName, responseJSON){ 
				if(responseJSON.success){
				$('#userPhoto').html('<img src=\"" . getRequestbaseUrl() . getuploadFolderDir() . $profiles->user_id . "/profile/432X324/'+responseJSON.filename+'\" />');
				$('#userPhotomessage').text('photo changed successfully.');
                                 $('#userPhotomessage').delay(3000).fadeOut('slow');}
			   
			   }"
                    )
                ));
                ?>

            </div>   
        </div> <!--figure div ends here--> 

        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 column6 my-detail">             
            <div id="formResult"></div>           
            <div class="form-group">
                <div class="row">    
                    <div class="col-lg-6 col-md-6 col-sm-4 column6">
                        <?php echo $form->labelEx($profiles, 'first_name'); ?>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-8 right-pad column6">
                        <?php echo $form->textField($profiles, 'first_name', array('title' => 'First Name', 'class' => 'form-control book-control')); ?>
                        <div class="errorMessage" id="Profiles_first_name_em_"></div>


                    </div>
                </div>        
            </div><!--form group close-->

            <div class="form-group">
                <div class="row">    
                    <div class="col-lg-6 col-md-6 col-sm-4 column6">
                        <?php echo $form->labelEx($profiles, 'last_name'); ?>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-8 right-pad column6">
                        <?php echo $form->textField($profiles, 'last_name', array('title' => 'Last Name', 'class' => 'form-control book-control')); ?>
                        <?php echo $form->error($profiles, 'last_name'); ?>
                    </div>
                </div>        
            </div><!--form group close-->

            <div class="form-group">
                <div class="row">    
                    <div class="col-lg-6 col-md-6 col-sm-4 column6 ">
                        <?php echo $form->labelEx($profiles, 'phone'); ?>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-8 right-pad column6">
                        <?php echo $form->textField($profiles, 'phone', array('title' => 'Phone Number', 'class' => 'form-control book-control')); ?>
                        <div class="errorMessage" id="Profiles_phone_em_"></div>

                    </div>
                </div>        
            </div><!--form group close-->

            <div class="form-group">
                <div class="row">    
                    <div class="col-lg-6 col-md-6 col-sm-4 column6">
                        <?php echo $form->labelEx($profiles, 'date_of_birth'); ?>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-8 right-pad column6">
                        <?php echo $form->textField($profiles, 'date_of_birth', array('class' => 'span2 form-control book-control', 'title' => 'date_of_birth', 'id' => 'dp1Datepiker', 'autocomplete' => 'on', 'data-date-format' => "yyyy-dd-mm", 'readony' => 'readonly','onclick'=>'hasDatepicker(this.id)')); ?><span class="dob-icon"></span>
                        <div class="errorMessage" id="Profiles_date_of_birth_em_"></div>
                    </div>
                </div>        
            </div><!--form group close-->
            <?php /* <div class="form-group">
              <div class="row">
              <div class="col-lg-6 col-md-6 col-sm-4 column6">
              <?php echo $form->labelEx($profiles, 'age'); ?>
              </div>
              <div class="col-lg-6 col-md-6 col-sm-8 right-pad column6">
              <?php echo $form->textField($profiles, 'age', array('class' => 'span2 form-control book-control', 'title' => 'date_of_birth', 'id' => 'dp1', 'autocomplete' => 'on', 'data-date-format' => "yyyy-dd-mm")); ?><span class="dob-icon"></span>
              <div class="errorMessage" id="Profiles_age_em_"></div>
              </div>
              </div>
              </div> */ ?>
            <div class="form-group">
                <div class="row">    
                    <div class="col-lg-6 col-md-6 col-sm-4 column6">
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-8 right-pad column6" id="change-password-clickfunction">
                        <a data-toggle="modal" data-target="#change-password" onclick="chnagePassword();">change password ?</a>
                        <div id="change-password-result"></div>
                    </div>
                </div>        
            </div>
            <div class="changePassrender" style="display: none">
                <?php $this->renderPartial('_changepassword'); ?>
            </div>



        </div>

    </div>



    <!-- About experience and other info section -->
    <section id="other-info">
        <div class="row">
            <div class="col-lg-12 column12 padding-zero-left">
                <div class="form-group">
                    <?php echo $form->labelEx($profiles, 'about'); ?>
                    <?php
                    $this->widget('common.extensions.ckeditor.CKEditor', array(
                        'model' => $profiles,
                        'attribute' => 'about',
                    ));
                    ?>
                    <div class="errorMessage" id="Profiles_about_em_"></div>
                </div>  

                <div class="form-group">
                    <?php echo $form->labelEx($profiles, 'experience'); ?>
                    <?php
                    $this->widget('common.extensions.ckeditor.CKEditor', array(
                        'model' => $profiles,
                        'attribute' => 'experience',
                    ));
                    ?>
                    <div class="errorMessage" id="Profiles_experience_em_"></div>

                </div>  

                <div class="form-group">
                    <?php echo $form->labelEx($profiles, 'other_info'); ?>
                    <?php
                    $this->widget('common.extensions.ckeditor.CKEditor', array(
                        'model' => $profiles,
                        'attribute' => 'other_info',
                    ));
                    ?>
                    <div class="errorMessage" id="Profiles_other_info_em_"></div>
                </div>

                <!--                <div class="form-group">
                                    <div class="checkbox choice">
                
                                        <input type="checkbox"  name="isCorporate" id="isCorporate" value="1" <?php if ($isCorporate || $corporateprogram->bank_name <> "") { ?> checked="checked" <?php } ?>  onclick="return showCorporate(this.id);"> 
                                        <label for="isCorporate">Get Would you like to be included as a trainer in our corporate program?</label>
                                    </div>
                
                                </div>  -->

            </div>
        </div>
    </section>
    <!-- About experience and other info section ends here -->
    <?php /*

      <!-- Bank detail section starts here -->
      <section id="bank-detail">
      <div class="row">
      <div class="col-lg-12 column12">
      <h3>bank account detail</h3>
      </div>


      <div class="form-group">
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'bank_name'); ?>
      <?php echo $form->textField($corporateprogram, 'bank_name', array('maxlength' => 45, 'title' => 'Bank Name', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'bank_name'); ?>
      </div>

      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'account_number'); ?>
      <?php echo $form->textField($corporateprogram, 'account_number', array('maxlength' => 45, 'title' => 'Bank Name', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'account_number'); ?>

      </div>
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'IFS_code'); ?>
      <?php echo $form->textField($corporateprogram, 'IFS_code', array('maxlength' => 45, 'title' => 'Bank Name', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'IFS_code'); ?>
      </div>
      </div>
      <div class="form-group">
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'PAN'); ?>
      <?php echo $form->textField($corporateprogram, 'PAN', array('maxlength' => 45, 'title' => 'Bank Name', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'PAN'); ?>
      </div>
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'branch_name'); ?>
      <?php echo $form->textField($corporateprogram, 'branch_name', array('maxlength' => 45, 'title' => 'Bank Name', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'branch_name'); ?>
      </div>
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'account_holder_name'); ?>
      <?php echo $form->textField($corporateprogram, 'account_holder_name', array('maxlength' => 45, 'title' => 'Bank Name', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'account_holder_name'); ?>
      </div>
      </div>
      <div class="form-group">
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'account_type'); ?>
      <?php echo $form->dropDownList($corporateprogram, 'account_type', array("current" => "Current", "saving" => "Saving"), array('empty' => 'Select Account Type', 'title' => 'Bank Account Type', 'class' => 'actype')); ?>
      <?php echo $form->error($corporateprogram, 'account_type'); ?>
      </div>
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'service_tax'); ?>
      <?php echo $form->textField($corporateprogram, 'service_tax', array('maxlength' => 45, 'title' => 'Service Tax Number', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'service_tax'); ?>

      </div>
      <div class="col-lg-4 col-md-4 col-sm-4 column4">
      <?php echo $form->labelEx($corporateprogram, 'TDS'); ?>
      <?php echo $form->textField($corporateprogram, 'TDS', array('maxlength' => 45, 'title' => 'TDS Number', 'class' => 'form-control book-control')); ?>
      <?php echo $form->error($corporateprogram, 'TDS'); ?>

      </div>
      </div>

      </div>
      </section><!--bank detail section ends here -->
     * */ ?>



    <!-- social detail section ends here -->
    <section id="social-detail">
        <div class="row">
            <div class="col-lg-12 column12 mopo">
                <h3>social network detail</h3>
            </div>


            <div class="form-group">
                <div class="col-lg-4 col-md-4 col-sm-4 column4 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'facebook'); ?>
                    <?php echo $form->textField($profiles, 'facebook', array('maxlength' => 45, "placeholder" => "Link", 'title' => 'Facebook Link', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_facebook_em_"></div>

                </div>
                <div class="col-lg-4 col-md-4 col-sm-4 column4 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'twitter'); ?>
                    <?php echo $form->textField($profiles, 'twitter', array('maxlength' => 45, "placeholder" => "Link", 'title' => 'Twitter Link', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_twitter_em_"></div>
                </div>
                <div class="col-lg-4 col-md-4 col-sm-4 column4 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'linkedin'); ?>
                    <?php echo $form->textField($profiles, 'linkedin', array('maxlength' => 45, "placeholder" => "Link", 'title' => 'Linkedin Link', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_linkedin_em_"></div>
                </div>
                <div style="clear:both;"></div>
            </div>  

            <div class="form-group">
                <div class="col-lg-4 col-md-4 col-sm-4 column4 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'website_title'); ?>
                    <?php echo $form->textField($profiles, 'website_title', array('maxlength' => 45, "placeholder" => "Title", 'title' => 'Website Title', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_website_title_em_"></div>
                </div>
                <div class="col-lg-8 col-md-8 col-sm-8 column8 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'website_link'); ?>
                    <?php echo $form->textField($profiles, 'website_link', array('maxlength' => 45, "placeholder" => "Link", 'title' => 'Website Link', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_website_link_em_"></div>
                </div>

            </div>  

            <div class="form-group">
                <div class="col-lg-4 col-md-4 col-sm-4 column4 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'blog_title'); ?>
                    <?php echo $form->textField($profiles, 'blog_title', array('maxlength' => 45, "placeholder" => "Link", 'title' => 'Website Link', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_blog_title_em_"></div>
                </div>
                <div class="col-lg-8 col-md-8 col-sm-8 column8 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'blog_link'); ?>
                    <?php echo $form->textField($profiles, 'blog_link', array('maxlength' => 45, "placeholder" => "Link", 'title' => 'Blog Link', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_blog_link_em_"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-lg-4 col-md-4 col-sm-4 column4 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'others'); ?>
                    <?php echo $form->textField($profiles, 'others', array('maxlength' => 45, "placeholder" => "Title", 'title' => 'Other Title', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_others_em_"></div>

                </div>
                <div class="col-lg-8 col-md-8 col-sm-8 column8 padding-zero-left">
                    <?php echo $form->labelEx($profiles, 'others_link'); ?>
                    <?php echo $form->textField($profiles, 'others_link', array('maxlength' => 45, "placeholder" => "Link", 'title' => 'Other Link', 'class' => 'form-control book-control')); ?>
                    <div class="errorMessage" id="Profiles_others_link_em_"></div>
                </div>
            </div>




        </div>
    </section><!--social-detail ends here-->
    <!--terms and condition ends here-->
    <section id="terms">
        <div class="row"> 
            <div class="col-lg-12 column12 padding-zero-left"> 
                <h3>TERMS AND CONDITIONS</h3>
                <div class="conditions">
                    <?php echo $termcondition_value; ?>
                </div>    



                <div class="form-group">
                    <div class="checkbox choice">
                        <?php $checked = ($profiles->first_name <> "") ? 'checked' : ''; ?>
                        <?php echo $form->checkbox($profiles, 'termcondition', array('checked' => $checked)); ?>
                        <label for="Profiles_termcondition">I have read the terms &amp; conditions</label><span style="color:#FF0000;">*</span>
                        <div class="errorMessage" id="Profiles_termcondition_em_"></div>
                    </div>

                </div>  

                <div class="form-group">
                    <div class="checkbox choice">
                        <?php echo CHtml::CheckBox('RegistrationForm[issubscribe]', $profiles->user->issubscribe, array('value' => '1', 'autocomplete' => 'off')); ?>
                        <label for="RegistrationForm_issubscribe"><?php echo Message::SUBSCRIVE_NEWS_LETTER; ?></label>

                        <?php //echo GxHtml::submitButton(Yii::t('app', 'Recommend'), array('id' => 'recommend_to_frd', 'onclick=send();')); ?>

                        <?php
                        echo CHtml::ajaxSubmitButton('Submit', CHtml::normalizeUrl(array('Users/updateprofile')), array(
                            'dataType' => 'json',
                            'type' => 'post',
                            'success' => 'function(data) {
                         $("#profileLoder").hide();  
                        if(data.status=="success"){
                        window.location = "#breadcrumb";
                         $("#formResult").html("Your profile has been update successfully.");
                                     
                         }
                         else{     
                         $("#formResult").html("");
                         $.each(data, function(key, val) {                    
                        $("#profiles-form #"+key+"_em_").text(val);                                                    
                        $("#profiles-form #"+key+"_em_").show();
                        });
                        }       
                    }',
                            'beforeSend' => 'function(){                        
                           $("#profileLoder").show();
                      }'
                                ), array('id' => 'query-btn', 'class' => 'pull-right', 'onclick' => 'CKEDITOR.instances.Profiles_about.updateElement(),CKEDITOR.instances.Profiles_experience.updateElement(),CKEDITOR.instances.Profiles_other_info.updateElement()'));
                        ?> <div id="profileLoder" style="display: none">
                            <img  class="reviewloader"src="<?php echo ThemePath(); ?>/images/myskill.gif"></img></div>    


                    </div>
                </div> 

            </div>
        </div>
    </section>

</div><!-- tab-pan ends here-->

<?php $this->endWidget(); ?>
<script>
                            function chnagePassword() {
                                $("#change-password-result").text('');
                                $(".changePassrender").slideToggle("slow", function() {                                    // Animation complete.
                                });
                                $("#change-password-clickfunction").slideToggle("slow", function() {
                                });
                            }

                            $("#submit-change-password").click(function() {
                                var password = $("#change_password").val();
                                var repassword = $("#change_repassword").val();
                                if (password == '') {
                                    $("#change_password-error").text('Enter the password');
                                    return false;
                                }
                                else if (repassword == '') {
                                    $("#change_password-error").hide();
                                    $("#confirm_password_password-error").text('Enter the repassword');
                                    return false;
                                }
                                else if (password != repassword) {
                                    $("#confirm_password_password-error").hide();
                                    $("#not-matchconfirm_password_password-error").text('Password do not match retypepassword');
                                    return false;
                                }
                                else {
                                    jQuery.ajax({
                                        'type': 'POST',
                                        'url': "<?php echo Yii::app()->createAbsoluteUrl("Users/changepassword"); ?>",
                                        'data': 'YII_CSRF_TOKEN=' + $('input[name="YII_CSRF_TOKEN"]').val() + "&password=" + password,
                                        'beforeSend': function(jqXHR, settings) {
                                            jQuery('#progressbar').show();
                                        },
                                        'success': function(data) {
                                            jQuery('#progressbar').hide();
                                            $(".changePassrender").slideToggle("slow", function() {                                    // Animation complete.
                                            });
                                            $("#change-password-clickfunction").slideToggle("slow", function() {
                                            });
                                            $("#change-password-result").text('Your password changed successfully.')

                                        },
                                        'cache': false
                                    });
                                }
                            })
                            function hasDatepicker(id) {
                                $("#" + id).attr('readonly', 'readonly');
                                $("#" + id).removeClass('hasDatepicker').datepicker({
                                    changeMonth: true,
                                    changeYear: true,
                                    stepMonths: 12,
                                    showButtonPanel: false,
                                    maxDate: 0,
                                    dateFormat: 'yy-mm-dd',
                                    yearRange: "-70:+0"
                                }).focus();
                            }
</script>
